package principle;

public class Principle {
    public static void main(String[] args) {
        Laowang laowang = new Laowang();
        Car car = new Car();
        AirPort airPort=new AirPort();
        //给老王汽车
        laowang.goToBeijing(car);
        //给老王飞机
        laowang.goToBeijing(airPort);
    }
}
class Laowang{
    public  void  goToBeijing(Vehicle vehicle){
        System.out.println("老王开着"+vehicle.name+"去北京");
        Car car = new Car();
    }
}

//交通工具类
class Vehicle{
   public String name;
}
//汽车类
class Car extends Vehicle{
    public Car(){
        super.name="汽车";
    }
}
//飞机类
class AirPort extends Vehicle{
    public AirPort(){
        super.name="飞机";
    }
}
